<!DOCTYPE html>
<html lang="en">
	<head>
		<title>退付书</title>
		<#include "../inc/header.ftl"/>
	</head>

	<body class="no-skin">

		<div class="main-container ace-save-state" id="main-container">

			<div class="main-content">
				<div class="main-content-inner">

					<div class="page-content">
						<div class="row">
                            <div id="grid-main-data" class="col-xs-12">
                                <table id="MainGrid" style="min-height: 500px"></table>
								<div id="toolbar">
									<div style="padding:8px">
                                        退付书号：<input id="billnumfind" class="easyui-textbox" style="width:140px">&emsp;
                                        交易流水号：<input id="bankaffirmfind" class="easyui-textbox" style="width:140px">&emsp;
                                        付款账户：<input id="bankidfind">
                                        付款日期：<input id="paybankdtfind" class="easyui-datebox" style="width:140px">&emsp;

                                        <a href="#" onclick="javascript:searchInfo()" class="easyui-linkbutton" iconCls="icon-search">查 询</a>
									</div>
									<div style="padding:8px 8px 4px">
										<a href="#" class="easyui-linkbutton" iconCls="icon-redo" onclick="javascript:sendInfo(1)">发送</a>
                                        <a href="#" class="easyui-linkbutton" iconCls="icon-back" onclick="javascript:sendInfo(2)">冲销</a>
                                        <a href="#" class="easyui-linkbutton" iconCls="icon-print" onclick="javascript:exportInfo()">导出</a>
									</div>
								</div>
							</div>
						</div><!-- /.row -->
					</div><!-- /.page-content -->

                    <!-- 发送复核 -->
                    <#include "../inc/fuhe.ftl"/>

                </div>
			</div><!-- /.main-content -->
		</div><!-- /.main-container -->

		<!-- basic scripts -->
		<#include "../inc/basicjs.ftl"/>

		<!-- inline scripts related to this page -->
		<script type="text/javascript">

            jQuery(function($) {
                $('#MainGrid').datagrid({
                    url:prefix + '/bill/backpaybill/findBackPayBillPage',
                    pagination: true,
                    fitColumns:false,
                    striped: true,
                    singleSelect: false,
                    loadMsg: "正在加载数据，请稍后...",
                    queryParams: {},
                    columns:[[
                        {field: 'ck', checkbox: true},
                        {title:'退付书号',field:'backbillnum',width:100},
                        {title:'区域编码名称',field:'cantonname',width:100},
                        {title:'单位编码名称',field:'unitname',width:160},
                        {title:'收款人',field:'drawman',width:150},
                        {title:'收款账号',field:'drawaccount',width:150},
                        {title:'收款开户行名称',field:'drawbank',width:100},
                        {title:'项目编码名称',field:'itemname',width:100},
                        {title:'金额',field:'fund',width:100},
                        {title:'付款时间', field:'dealdate',width:140},
                        {title:'付款人账户名称', field:'accountname',width:150},
                        {title:'付款账号',field:'accountcode',width:150},
                        {title:'付款开户行名称',field:'bankname',width:150},
                        {title:'付款网点',field:'bankstation',width:130},
                        {title:'交易流水号',field:'bankaffirm',width:140},
                    ]],
                    toolbar: '#toolbar',
                    onBeforeLoad: function (param) {
                        // 首次打开时，不加载数据
                        var firstLoad = $(this).attr("firstLoad");  
                        if (firstLoad == "false" || typeof (firstLoad) == "undefined") {  
                            $(this).attr("firstLoad","true");  
                            return false;  
                        }  
                        return true;  
                    },
                    onLoadSuccess: function (data) {
                        if (data.total == 0) {
                            $('#grid-main-data').find('.datagrid-body').html('<div style="text-align: center;font-size: 14px;padding: 20px 0;">查询无数据</div>');
                        }
                    }
                });

                $(window).resize(function() {
                    $('#MainGrid').datagrid('resize');
                });
                // 查询的下拉框
                $('#bankidfind').combogrid({
                    panelWidth:550,
                    idField:'bankid',
                    textField:'accountcode',
                    data: _bankdata,
                    columns:[[
                        {field: 'ck', checkbox: true},
                        {field:'cantonname',title:'区划',width:80},
                        {field:'accountcode',title:'账号',width:160},
                        {field:'bankname',title:'开户行名称',width:260}
                    ]]
                });
            });

			function searchInfo() {
                if ($('#bankidfind').val() == '') {
                    $.messager.alert('提示', '请选择收款账户', 'info');
                    return;
                }
                $('#MainGrid').datagrid('load', {
                    bankid: $('#bankidfind').val(),
                    dealdate: $('#paybankdtfind').val(),
                    bankaffirm: $('#bankaffirmfind').val(),
                    backbillnum: $('#billnumfind').val()
                });
			}

            //----------------------- 发送弹窗
            function sendInfo(opt) {
                if(opt==1){
                    send_tit = "发送";
                    send_url = "/bill/backpaybill/sendBackpaybill";
                    send_reload = 0;
                }else{
                    send_tit = "冲销";
                    send_url = "/bill/backpaybill/cleanBackpaybill";
                    send_reload = 1;
                }
                openSendBox();
                var row = $('#SendMainGrid').datagrid('getData');
                $.each(row.rows,function(index, value) {
                    value.billid = value.backbillid
                });
            }
            function exportInfo() {
                var bankid = $('#bankidfind').val();
                if (bankid == '') {
                    $.messager.alert('提示', '请选择付款账户', 'info');
                    return;
                }
                var paybankdt = $('#paybankdtfind').val();
                if (paybankdt == '') {
                    $.messager.alert('提示', '请选择付款日期', 'info');
                    return;
                }
                var downurl = prefix + '/bill/backpaybill/backPayBillExport?bankid=' + bankid + '&paybankdt=' + paybankdt;
                window.location.href = downurl;
            }

        </script>
	</body>
</html>
